package 双指针.盛水最多的容器;

public class MoreWater {
    public static void main(String[] args) {
        Solution so = new Solution();
        int[] arr ={1,8,6,2,5,4,8,3,7};
        System.out.println(so.maxArea(arr));
    }
}
class Solution {
    public int maxArea(int[] height) {
        int left = 0,right = height.length-1;
        int Max = 0;
        while(left < right){
            int w = right - left;
            int h = Math.min(height[left],height[right]);
            int v = w * h;
            Max = Math.max(Max,v);
            if(height[left]<height[right]){
                left++;
            }else{
                right--;
            }
        }
        return Max;
    }
}